package org.smr.ministore.micro;

import java.util.List;

import org.blade.dao.base.BaseMapper;
import org.blade.utils.IdGenUtils;
import org.smr.ministore.dao.GoodsTypePropsValueMapper;
import org.smr.ministore.entities.GoodsTypePropsValue;
import org.smr.ministore.service.GoodsTypePropsValueService;
import org.blade.service.base.AbstractService;

import org.blade.utils.Pager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class GoodsTypePropsValueMicroService extends AbstractService<Long,GoodsTypePropsValue> implements GoodsTypePropsValueService {

	@Autowired
	private GoodsTypePropsValueMapper mapper;

	@Autowired
    public GoodsTypePropsValueMicroService(GoodsTypePropsValueMapper mapper) {
        super(mapper);
    }

    @ResponseBody
	@RequestMapping(method = RequestMethod.POST, value = "/GoodsTypePropsValue/batchSave")
	public int batchSave(@RequestBody List<GoodsTypePropsValue> entities) {
        this.batchSaveAttatch(entities);
    	return mapper.batchInsert(entities);
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.POST, value = "/GoodsTypePropsValue/batchModify")
    public int batchModify(List<GoodsTypePropsValue> entities) {
        this.batchModifyAttatch(entities);
        return mapper.batchUpdate(entities);
    }


    @ResponseBody
    @RequestMapping(method = RequestMethod.PUT, value = "/GoodsTypePropsValue/save")
    public int save(@RequestBody GoodsTypePropsValue entity) {
        this.saveAttatch(entity);
    	return mapper.insert(entity);
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.PATCH, value = "/GoodsTypePropsValue/updateById")
    public int updateById(@RequestBody GoodsTypePropsValue id) {
        this.modifyAttach(id);
   	 	return mapper.updateById(id);
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.GET, value = "/GoodsTypePropsValue/queryById/{id}")
    public GoodsTypePropsValue queryById( @PathVariable("id")Long id ) {
    	return (GoodsTypePropsValue) mapper.selectById(id);
    }

    @ResponseBody
    @RequestMapping(method = RequestMethod.DELETE, value = "/GoodsTypePropsValue/deleteById/{id}")
    public int deleteById( @PathVariable("id")Long id ) {
        return mapper.deleteById(id);
    }

    @Override
    @ResponseBody
    @RequestMapping(method = RequestMethod.DELETE, value = "/GoodsTypePropsValue/deleteByIdLogical/{id}")
    public int deleteByIdLogical(@PathVariable("id") Long id) {
        return this.mapper.deleteByIdLogical(id);
    }

    @ResponseBody
    @RequestMapping( method = RequestMethod.POST, value = "/GoodsTypePropsValue/paginate/{pageSize}/{pageNum}")
    public Pager<GoodsTypePropsValue> paginate( GoodsTypePropsValue entity, @PathVariable("pageSize")Long pageSize,  @PathVariable("pageNum")Long pageNum ) {
        Pager<GoodsTypePropsValue> pager = new Pager(pageSize, pageNum);
        List<GoodsTypePropsValue> list = this.mapper.pagination( entity, pager );
        pager.setEntities(list);
        return pager;
    }


    @Override
    public Long getId() {
        return IdGenUtils.getNextLongId();
    }
}
